home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 2 / CU Amiga Magazine's Super CD-ROM 02 (1996)(EMAP Images)(GB)[!][issue 1996-04].iso / magazine / amiga_e / amigae.june.archive / 000048_crash!kirk.safb.af.mil!BWILLS_Thu, 10 Jun 93 17:50:47 PST.msg < prev    next >
Text File  |  1993-08-31  |  4KB  |  86 lines

  1. Received: by bkhouse.cts.com (V1.16/Amiga)
  2.     id AA00000; Thu, 10 Jun 93 17:50:47 PST
  3. Received: from kirk.safb.af.mil by crash.cts.com with smtp
  4.     (Smail3.1.28.1 #15) id m0o3wEv-00003sC; Thu, 10 Jun 93 16:41 PDT
  5. Message-Id: <m0o3wEv-00003sC@crash.cts.com>
  6. Date: 10 Jun 93 18:38:00 CST
  7. From: "Barry D. Wills" <BWILLS@kirk.safb.af.mil>
  8. To: "amigae" <amigae@bkhouse.cts.com>
  9. Subject: LIST2.E (re:  Son Le's lists/linked lists questions)
  10.  
  11. /* It looked like this was undelivered, so here it is again.  This is part 2. */
  12. /* LIST2.E - In response to Son Le's linked list question. */
  13.  
  14. PROC main ()
  15.   DEF a [3] : STRING,
  16.       b [3] : STRING,
  17.       c [3] : STRING,
  18.       d [3] : STRING
  19.  
  20.   StrCopy (a, 'aaa', ALL)
  21.   StrCopy (b, 'bbb', ALL)
  22.   StrCopy (c, 'ccc', ALL)
  23.   StrCopy (d, 'ddd', ALL)
  24.  
  25.   WriteF ('d.next=\s\n', IF Next(d)=NIL THEN 'NIL' ELSE Next(d))
  26.  
  27.   /*------------*/
  28.   d:=Link(d,NIL)    /* At this point does nothing:  d.next is already NIL. */
  29.   /*------------*/
  30.  
  31.   /*------------*/
  32.   d:=Link(c,d)
  33.   /*------------*/
  34.  
  35.   /* c.next points to the string 'ddd'; d now points to the string 'ccc' */
  36.   /* because Link() returns the address of c.  Now the string 'ddd' can  */
  37.   /* only be accessed via Next(c).                                       */
  38.   WriteF ('a=\s b=\s c=\s d=\s c.next=\s\n', a, b, c, d, Next(c))
  39.  
  40.   /*------------*/
  41.   d:=Link(b,d)
  42.   /*------------*/
  43.  
  44.   /* b.next points to the string 'ccc' because d was reassigned the     */
  45.   /* address of 'ccc' in the previous Link() statement; d now points to */
  46.   /* the string 'bbb' because Link() returns the address of b.          */
  47.   WriteF ('b=\s b.next=\s d=\s\n', b, Next(b), d)
  48.  
  49.   /*------------*/
  50.   d:=Link(a,d)
  51.   /*------------*/
  52.  
  53.   /* a.next points to the string 'bbb' because d was reassigned the     */
  54.   /* address of 'bbb' in the previous Link() statement; d now points to */
  55.   /* the string 'aaa' because Link() returns the address of a.          */
  56.   WriteF ('a=\s a.next=\s d=\s\n', a, Next(a), d)
  57.  
  58.   /* Finally, everything that can be gotten from the linked strings:  */
  59.   WriteF ('a=\s  -> \s\n', a, Next(a))
  60.   WriteF ('b=\s  -> \s\n', b, Next(b))
  61.   WriteF ('c=\s  -> \s\n', c, Next(c))
  62.   WriteF ('d=\s  -> \s\n', d, Next(d))
  63.  
  64.   /***************************************************************************/
  65.   /* The final output of the program is:                                     */
  66.   /*                                                                         */
  67.   /* a=aaa  -> bbb                                                           */
  68.   /* b=bbb  -> ccc                                                           */
  69.   /* c=ccc  -> ddd                                                           */
  70.   /* d=aaa  -> aaa                                                           */
  71.   /*                                                                         */
  72.   /* Compare the values pointed to by the Next() links in this program and   */
  73.   /* list1.e.  This is the difference in what the code does, not to mention  */
  74.   /* the different routes used to get there.                                 */
  75.   /*                                                                         */
  76.   /* Hope this sheds *some* light!  It might help if you're familiar with    */
  77.   /* how the DrawBorder() graphics function works on border structures that  */
  78.   /* are linked together, and how the DrawText() intuition function works on */
  79.   /* intuitext structures that are linked together.  Also, the functions     */
  80.   /* MapList(), ForAll(), and Exists() only work on a single list variable,  */
  81.   /* NOT on linked lists.  I haven't found a good example for using these    */
  82.   /* yet.  Maybe later.  -- Barry                                            */
  83.   /***************************************************************************/
  84.  
  85.   CleanUp (0)
  86. ENDPROC